<?php
require '../main.php';
function plantilla_bloques($path,$title,$description)
{
	return <<<HTML
<div class="bloque">
	<h4><a href="$path/demo.php" target="demos">$title</a></h4>
	<p>$description</p>
</div>
HTML;
}
?>
<style type="text/css">
html,body{
height:100%;
border:none;
padding:0;
margin:0;
}
.bloque {border:1px solid blue; width:200px;}
.bloque h4{padding:0px;margin:0px;}
.bloque p{padding:0px;margin:0px;}

.bloque p{padding:0px 5px;}
.myIframe{
	border:inset 2px green;
	width:100%;
}
.paginator{
	height:30px;
}
.paginator a{
	display: inline-block;
	border:1px solid blue;
	border-radius:2px;
	padding:1px;
	margin:0px 2px;
	font-family:monospaced;
	font-size:10px;
}
.paginator a{ border-color:#aaa}
.paginator a[href]
{
	border-color: green;
}
</style>
<table width="100%"  height="100%">
	<tr valign="top">
		<td style="width:200px;">
<?php
class filtro_directorio extends FilterIterator
{
/*	private $userFilter;
    public function __construct(Iterator $iterator , $filter )
    {
        parent::__construct($iterator);
        $this->userFilter = $filter;
    }*/
	public function accept()
	{
		return $this->current()->isDir() && !$this->current()->isDot();
	}
}
//$hoja = 0;
$directorio = new filtro_directorio(new DirectoryIterator(__DIR__.DS.'programacion')) ;
//echo iterator_count($directorio);
$paginator = new paginator(iterator_count($directorio));
$paginator->resultsPerPage(2);
$paginator->currentPage(system::getNotEmpty($_GET['hoja'],1));
$paginator->paginate();
?>
<div class="paginator">
<?php	foreach($paginator->arrayPages() as $page){
	if($page != $paginator->getcurrentPage())
	{
		echo '<a href="?hoja='. $page .'">'.  $page .'</a>';
	}
	else
	{
		echo '<a>'.  $page .'</a>';
	}
}?>
</div>
<?php
foreach(new LimitIterator($directorio,$paginator->getFirst(),2) as $dir)
{
		$xml = simplexml_load_file($dir->getPathname() .DS .'data.xml');
		echo plantilla_bloques('/monvic/portafolio/programacion/'.$dir->getFilename(),$xml->title,$xml->description);
}
?>	
		</td>
		<td>
			<iframe class="myIframe" src="" frameborder="0" name="demos" height="99%"  style="width:98%"></iframe>
		</td>
	</tr>
</table>

